package com.kcwl.carrier.domain.service;

import com.kcwl.carrier.domain.entity.QualificationInfo;
import com.kcwl.carrier.domain.repository.IQualificationInfoRepository;
import com.kcwl.carrier.infrastructure.repository.po.QualificationInfoPO;
import com.kcwl.carrier.interfaces.dto.QualificationListDTO;
import com.kcwl.carrier.interfaces.query.QualificationInfoQuery;
import com.kcwl.ddd.infrastructure.utils.KcPageConverter;
import com.kcwl.ddd.interfaces.dto.PageInfoDTO;
import com.kcwl.framework.utils.KcBeanConverter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @描述 车辆信息
 * @创建人 zhl
 * @创建时间 2022/11/1
 * @修改人和其它信息
 */
@Service
public class QualificationInfoDomainService {
    @Autowired
    private IQualificationInfoRepository qualificationInfoRepository;

    public QualificationInfo getByBizId(QualificationInfo qualificationInfo) {
        return KcBeanConverter.toBean(qualificationInfoRepository.getByBizId(qualificationInfo), QualificationInfo.class);
    }
    public QualificationInfo getById(Long id) {
        return KcBeanConverter.toBean(qualificationInfoRepository.getById(id), QualificationInfo.class);
    }

    public Boolean updateById(QualificationInfo qualificationInfo) {
        return qualificationInfoRepository.updateById(KcBeanConverter.toBean(qualificationInfo, QualificationInfoPO.class));
    }

    public Boolean insert(QualificationInfo qualificationInfo) {
        return qualificationInfoRepository.save(KcBeanConverter.toBean(qualificationInfo, QualificationInfoPO.class));
    }

    public PageInfoDTO<QualificationListDTO> queryQualificationInfoPage(QualificationInfoQuery query) {
       return KcPageConverter.toPageInfoDTO(qualificationInfoRepository.queryQualificationInfoPage(query), QualificationListDTO.class);
    }
}
